﻿@using PagedList.Mvc;
@model  Model.Product.ProductModel
@{
    PagedList.IPagedList<Model.Product.ProductModel> myPageList = (PagedList.IPagedList<Model.Product.ProductModel>)ViewBag.MyPageList;

    Layout = "~/Views/Shared/MyLayOutNew.cshtml";
}
<link href="~/Content/PagedList.css" rel="stylesheet" />
<main class="main-cont content mCustomScrollbar">
    <div class="page-wrap">
        <!--开始::内容-->
        <section class="page-hd">
            <header>
                <h2 class="title">商品管理>>商品管理</h2>
                <p class="title-description">
                    <button class="btn btn-primary" onclick="Edit('add','0');">新增</button>
                </p>
            </header>
            <hr>
        </section>
        <table class="table mb-15">
            <thead>
                <tr>
                    <th><input type="checkbox" /></th>
                    <th>名称</th>
                    <th>创建日期</th>
                    <th>创建用户</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>

                @foreach (var item in myPageList)
                {
                    <tr class="cen">
                        <td><input type="checkbox" /></td>
                        <td>
                            @Html.DisplayFor(modelItem => item.Name)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.CreateDate)
                        </td>
                        <td>
                            @Html.DisplayFor(modelItem => item.ChangeLoginName)
                        </td>
                        <td>
                            <a title="编辑" class="mr-5" onclick="Edit('edit',@item.ID);">编辑</a>
                           
                            <a title="删除" class="mr-5" onclick="Del(@item.ID);">删除</a>
                            
                        </td>
                    </tr>
                }

            </tbody>
        </table>
        每页 @myPageList.PageSize 条记录，共 @myPageList.PageCount 页，当前第 @myPageList.PageNumber 页
        @Html.PagedListPager(myPageList, page => Url.Action("Index", new { page }))
        <!--开始::结束-->
    </div>
</main>

@using (Html.BeginForm("SaveData", "Product", FormMethod.Post))
{
    <div class="page-wrap">
        <!--开始::内容-->
        <input type="hidden" id="ID" />
        <div class="form-group-col-2">
            <div class="form-label">商品标题：</div>
            <div class="form-cont">
                @Html.TextBoxFor(m => m.Name, new { @class = "form-control form-boxed" })

            </div>
        </div>


        <div class="form-group-col-2">
            <div class="form-label"></div>
            <div class="form-cont">
                <input type="submit" class="btn btn-primary" value="提交表单" />
                <input type="reset" class="btn btn-disabled" value="禁止" />
            </div>
        </div>
        <!--开始::结束-->
    </div>
}



<script type="text/javascript">
    function Edit(obj, id) {
            window.location.href = "/Product/EditNew?id="+id;
        }
    function Del(objid){
        $.ajax({
            url:'/Product/DelModel',
            type:'post',
            data:{id:objid},
            success:function(data){
                 
                window.location.href="/Product/Index";
            }
        })
    }
       
</script>

